

def print_file_info(file_name):
    f=None
    try:
        f=open(file_name,"r",encoding="UTF-8")
        print(f.read())
    except Exception as e:
        print(e)
    finally:
        if f:
            f.close()

def append_to_file(file_name,data):
    f=open(file_name,"a",encoding="UTF-8")
    f.write(data)
    f.flush()
    f.close()

if __name__=="__main__":
    print_file_info('/home/zjg/zjg1.txt')

    append_to_file('/home/zjg/zjg1.txt',"hello jingui!\nyou will get a good job!\n")
